<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="my" uri="/mytags" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>通知公告发布</title>
<link rel="stylesheet" type="text/css" href="asserts/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
	  <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/wangEditor-3.0.16/release/wangEditor.min.css"/>
 
		<!-- js插件 -->
		<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
		<script src="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/asserts/bootstrapValidate/css/bootstrapValidator.min.css"/>
 	   <script src="${pageContext.request.contextPath}/asserts/bootstrapValidate/js/bootstrapValidator.min.js"></script>
		<script src="${pageContext.request.contextPath}/js/wangEditor-3.0.16/release/wangEditor.min.js"></script>
		
</head>
<script>

 
$(function () {	  
	var E = window.wangEditor;
	//这里的id为<div id="editor"中的id.
	var editor = new E('#editor');
	//创建编辑器
	editor.create();
	
	
	$("#savebtn").click(function(){
	 	//验证公告标题
	 	var title = $("[name='name']").val();
	 	if(title==''){
	 		alert("请填写公告标题");
	 		return ;
	 	}
		//公告内容		
		var txt = editor.txt.html()
	 
		if(txt==''){
			alert("请填写公告内容");
			return;
		}
		//将富文本的内容放入隐藏域中
		$("#content").val(txt);

		//公告文件
	 	var filepath = $("[name='filepath']").val();
	 	if(filepath==''){
	 		alert("请选择公告文件");
	 		return ;
	 	}
	 	
	 	
		//提交
		$("form").submit();
	});

});

 

</script>
<body >
<div class="container-fluid a">
			<div class="row">
				<form action="${pageContext.request.contextPath}/notice/add"
				 method="post" enctype="multipart/form-data" class="form-horizontal col-md-10 col-md-offset-1">
					<h1>通知公告发布</h1>
					<hr/>
					<!-- 1.标题： -->
						<div class="form-group">
									<label class="control-label col-md-2">公告标题：</label>
									<div class="col-md-10">
										<input type="text" name="name"  class="form-control"  />
									</div>
						</div>
					 
						<div class="form-group">
									<label class="control-label col-md-2">公告内容：</label>
									<div class="col-md-10">
											<!-- 使用wangEdit -->
									    <div id="editor"></div>
									    <input type="hidden" name="content" id="content"/>
									</div>
						</div>
					 
						<div class="form-group">
										<label class="control-label col-md-2">公告文件：</label>
									<div class="col-md-10">
										 <input type="file"  name="filepath" class="form-control"  />
									</div>
						</div>
						 
					
						<div class="form-group">
									
									<div class="col-md-offset-2 col-md-8">
											<button class="btn btn-danger" data-dismiss="modal" onclick="javascript:void(-1)" type="button">返回</button>
											<button class="btn btn-primary" type="button"  id="savebtn">发布</button>
									</div>
						</div>
					
				</form>
				
			</div>
			
		</div>

</body>
</html>
 
